package com.ljx.stream.stream01;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Stream;

/**
 * @author LJX
 * @Description: 获取流对象的几种方式
 * @Date: 2022/11/4 16:05
 * @Version 1.0
 */
public class Stream02 {
	public static void main(String[] args) {
		ArrayList<Integer> arrayList = new ArrayList<>();
		Collections.addAll(arrayList,12,343,231,122);
		// 通过集合对象调用stream方法获取
		Stream<Integer> stream = arrayList.stream();


		//通过Arrays数组工具类调用stream流方法
		Integer[] arr={123,234,345,43};
		Stream<Integer> stream1 = Arrays.stream(arr);
		stream1.forEach(a-> System.out.println(a));

		// 通过Stream类中的方法获取Stream流对象
		Stream<Integer> stream2 = Stream.of(212, 123, 1523, 12, 31, 23, 234, 213);
		stream2.filter(a->a>230).forEach(a-> System.out.println(a));
	}
}
